
package biblio.exception;

/**
 * Exception which describes situation when Element wasn't found in the database
 * @author GM Mephisto
 * @since 2011-04-23
 */
public class NoSuchEntityException  extends BaseApplicationException
{
    public NoSuchEntityException(String id)
    {
        super("Element identified by id: " + id + " does not exist!");
    }

    public NoSuchEntityException(String id, Object elem)
    {
        this(id, elem, "Element identified by id: " + id + " does not exist!");
    }

    public NoSuchEntityException(String id, Object elem, String errMessage)
    {
        super(ERROR_CODE, errMessage);
        this.elem = elem; 
        this.id = id;
    }

    /**
     * @return the element which does not exist in the database
     * return null if to construct object was used such
     * constructor NoSuchEntityException(int id)
     */
    public Object getElement()
    {
        return elem;
    }

    /**
     *
     * @return id of the Element
     */
    public String getId()
    {
        return id;
    }


    private final static String ERROR_CODE = "noSuchElement";

    private String id;
    private Object elem;
}
